/*
 * yBlockingQueue.h
 *
 *  Created on: Sep 17, 2016
 *      Author: root
 */

#ifndef BASE_CONCURRENT_YBLOCKINGQUEUE_H_
#define BASE_CONCURRENT_YBLOCKINGQUEUE_H_

#include <iostream>
#include <pthread.h>
#include <stdlib.h>
#include "../yCommon.h"
using namespace std;


class BlockingQueue {
public:
	BlockingQueue();
	BlockingQueue(int capacity);
	~BlockingQueue();
	void put(void* item);
	void* take();

private:
	int capacity;
	void** queue;
	int head;
	int tail;
	pthread_mutex_t mutex;
	pthread_cond_t notFull, notEmpty;
};


#endif /* BASE_CONCURRENT_YBLOCKINGQUEUE_H_ */
